import React, { Component } from 'react'
import PropTypes from 'prop-types'
import InputOpenWin from '../InputOpenWin'
import {HTTP, getOrganNo} from "../../../utils";
import { archOpenWinList } from '../../../utils/api'


export default class extends Component {

    constructor(props) {
        super(props)
        this.input = undefined
    }

    componentDidMount() {
        if(this.props.initVal ===  undefined || this.props.initVal === null || this.props.initVal == "") {

        } else {
            HTTP.post(archOpenWinList, {id: this.props.initVal}, () => {
            }, (resp) => {
                const appName = ((((resp || {})['data'] || [])[0] || {}))['archName']
                this.input.setText(appName)
            })
        }

    }

    tableUrl = archOpenWinList

    tableColumn = [{
        title: '名称',
        dataIndex: 'archName',
        key: 'archName',
    }]

    render = () => {
        return (
            <InputOpenWin
                ref={(e) => {this.input=e}}
                tableTitle="应用列表"
                tableSeaField={this.tableSeaField}
                tableUrl={this.tableUrl}
                tableColumn={this.tableColumn}
                valueField="archName"
                keyField="id"
                tableSeaExtendVal={{organNo: getOrganNo(), level: 1}}
                {...this.props}
            />
        )
    }
}
